$(function () {
    let id = localStorage.getItem("id");
    console.log(id);
    findById(id);
});

function findById(id) {
    let result = myAjax('/back/room/findHomeById', 'get', {id: id,token:$.cookie("token")});
    let data = result.model;
    setData(data);
}
function setData(data) {
    $("#id").val(data.id);
    $("#backGround").val("");
    $("#title").val(data.title);
    $("#roomPhoto").val("");
    $("#href").val(data.href);
}
function homeEdit() {
    let data = new FormData();
    data.append("id", $("#id").val());
    data.append("backGround", $("#backGround").val());
    data.append("title", $("#title").val());
    data.append("roomPhoto", $("#roomPhoto").val());
    data.append("href", $("#href").val());
    data.append("token", $.cookie("token"));
    let result = imgMyAjax('/back/room/homeEdit', 'get', data);
    if (result === 1) {
        alert("修改成功");
        $("#right").load('../back/room/homeThreeRoom.html');
    } else {
        alert("修改失败");
    }
}

function cancelHomeEdit() {
    $("#right").load('../back/room/homeThreeRoom.html');
}